|
|
|
|
|
|
|
that they need to insert a disk and then wait for the user to correct the problem and click OK to continue the process. |
|
|
|
|
|
|
|
|
A program code error cannot be resolved by the user. These are generally programming problems caused by unexpected conditions that have occurred in the application code. The best way to deal with these errors is to tell the user to report the message to you and exit the program. After you have this information, you would need to find the problem in the application code, fix it, recompile the application, and then send the new executable file to the user. |
|
|
|
|
|
|
|
|
When you start designing and working with database applications, another type of error that occurs is the data-related error. These usually include those errors that deal with data type or field size problems, table access restrictions, duplicate or incorrect data added to the database, any SQL-related errors, or an empty recordset that shouldn't be empty. Database access falls into two categories that you have already worked with earlier in this book, Data Controls and Data Access Objects. The way you handle these access errors is unique to the access type. For most errors, all you need to do is trap the error, report it to the user, and enable the user to return to the data entry or display form to fix the problem. |
|
|
|
|
|
|
|
|
If you use the Data Control on your data forms, you can take advantage of the automatic database error reporting that is built into the Data Control. When you try to perform an action that is inherently incorrect for the database that the Data Control is connected to, the Data Control will trap the error and display a message to the user. The Data Control provides a complete database error reporting even if you have no error-handling routines in your Visual Basic application. Along with the automatic error handling provided, the Data Control also has an Error event that is triggered each time a data-related error occurs. You can add custom code to this event to fix some of the database errors for the user, or display a better, more understandable error message. |
|
|
|
|
|
|
|
|
Note It is usually not a good idea to override the default error routines of the Data Control with your own database error code. Al long as you use the Data Control, you don't need to add database error-handling routines to your application. However, if you need to perform special actions when a database error occurs, you would need to add code to the Data Control's Event routine. |
|
|
|
|
|
|